package com.vencent.struts2.interceptor;

import java.util.Random;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.MethodFilterInterceptor;

public class MyInterceptor3 extends MethodFilterInterceptor{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private static final Random random = new Random();

	@Override
	protected String doIntercept(ActionInvocation invocation) throws Exception {
		System.out.println("前置处理器");
		int temp = 0;
		if((temp = random.nextInt(2)) == 1){
			System.out.println(temp);
			return "toLogin";
		}
		String str = invocation.invoke();
		System.out.println("后置处理器");
		return str;
	}
	
}
